//
//  FindNameViewController.m
//  Family
//
//  Created by 王声䘵 on 2018/4/22.
//  Copyright © 2018年 王声䘵. All rights reserved.
//

#import "FindNameViewController.h"
#import "MyNavigationController.h"
#import "ViewController.h"
#import "Singleton.h"
@interface FindNameViewController ()

//1,movie 2.NameMessage 3.Famous 4.WhereName flag=1时向下动画，-1为向上动画，flagadd是被点击按钮下方的按钮详细内容是否向下移动

@property (weak, nonatomic) IBOutlet UIButton *whereName;
@property (weak, nonatomic) IBOutlet UIButton *moveBut;
@property (weak, nonatomic) IBOutlet UIScrollView *Scroll;
@property (weak, nonatomic) IBOutlet UIButton *nameMessage;
@property (weak, nonatomic) IBOutlet UIButton *famous;
@property(nonatomic)int flag;
@property(nonatomic)int flag2;
@property(nonatomic)int flag3;
@property(nonatomic)int flag4;
@property(nonatomic)int flagAdd1;
@property(nonatomic)int flagAdd2;
@property(nonatomic)int flagAdd3;
@property(nonatomic)int flagAdd4;
@property(nonatomic,strong)UITextView *text;
@property(nonatomic,strong)UITextView *text2;
@property(nonatomic,strong)UITextView *text3;
@property(nonatomic,strong)UITextView *text4;
@end

@implementation FindNameViewController
//头像按钮，现在是返回按钮
- (IBAction)touxiang:(id)sender {
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    _flag=1;
    _flag2=1;
    _flag3=1;
    _flag4=1;
    _flagAdd1=0;
    _flagAdd2=0;
    _flagAdd3=0;
    _flagAdd4=0;
    if(self.navigationController.navigationBar.isHidden==YES)
    {
        self.navigationController.navigationBar.hidden=NO;

        self.navigationController.navigationBar.backgroundColor=[UIColor grayColor];
    }
    else
    {
        
    }
    //滚动界面
     _Scroll.contentSize = CGSizeMake(322, SCREEN_SIZE.height*2);
    _Scroll.userInteractionEnabled = YES;
    _Scroll.showsVerticalScrollIndicator = NO;
    _text2=[[UITextView alloc]init];
    _text3=[[UITextView alloc]init];
    _text4=[[UITextView alloc]init];
    _text=[[UITextView alloc]init];
    [_moveBut addTarget:self action:@selector(Movie:) forControlEvents:UIControlEventTouchUpInside];
    [_whereName addTarget:self action:@selector(WhereName:) forControlEvents:UIControlEventTouchUpInside];
    [_famous addTarget:self action:@selector(Famous:) forControlEvents:UIControlEventTouchUpInside];
    [_nameMessage addTarget:self action:@selector(NameMessage:) forControlEvents:UIControlEventTouchUpInside];

    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
//视频
-(void)Movie:(UIButton *)but
{

    if(_flagAdd1==0)
    {
        _flagAdd1=1;
       
        _text.frame=CGRectMake(0,_moveBut.frame.origin.y+_moveBut.frame.size.height , 322, 0);
        _text.text=@"这是一堆文章这是一堆文章这是一堆文章这是一堆文章这是一堆文章这是一堆文章这是一堆文章这是一堆文章这是一堆文章这是一堆文章这是一堆文章这是一堆文章这是一堆文章这是一堆文章";
        // [_message addSubview:_text];
        [_Scroll addSubview:_text];
    }else{
        
    }
    //点击butten显示详细内容
    
    [UIView animateWithDuration:0.5 animations:^{
        CGRect frame=self.whereName.frame;
        CGRect frameNameMessage=_nameMessage.frame;
        CGRect frameFamous=_famous.frame;
        CGRect frameMovieText=_text.frame;
        CGRect frameWhereNameText=_text4.frame;
        CGRect frameNameMessageText=_text2.frame;
        CGRect frameFamousText=_text3.frame;
        if(_flagAdd1==1)
        {
           frameMovieText.size.height+=300*_flag;
            _text.frame=frameMovieText;
        }
        if(_flagAdd2==1){
            frameNameMessageText.origin.y+=300*_flag;
            _text2.frame=frameNameMessageText;
        }
        if(_flagAdd3==1)
        {
            frameFamousText.origin.y+=300*_flag;
            _text3.frame=frameFamousText;
        }
        if(_flagAdd4==1){
            frameWhereNameText.origin.y+=300*_flag;
             _text4.frame=frameWhereNameText;
        }
        frameNameMessage.origin.y+=300*_flag;
        frameFamous.origin.y+=300*_flag;
        frame.origin.y+=300*_flag;
        _text.backgroundColor=[UIColor grayColor];
        if(_flag==1)
        {
            _flag=-1;
        }else{
            _flag=1;
        }
        
        self.famous.frame=frameFamous;
        self.nameMessage.frame=frameNameMessage;
       
        self.whereName.frame=frame;
    }];
}
//简介

-(void)NameMessage:(UIButton *)but
{
    NSLog(@"NameMessage");
    if(_flagAdd2==0)
    {
        _flagAdd2=1;
       
        _text2.frame=CGRectMake(0,_nameMessage.frame.origin.y+_nameMessage.frame.size.height , 322, 0);
        _text2.text=@"这是一堆文章这是一堆文章这是一堆文章这是一堆文章这是一堆文章这是一堆文章这是一堆文章这是一堆文章这是一堆文章这是一堆文章这是一堆文章这是一堆文章这是一堆文章这是一堆文章";
        [_Scroll addSubview:_text2];
    }
    else{
        
    }
    //点击butten显示更多内容
    
    [UIView animateWithDuration:0.5 animations:^{
        CGRect frameFamous=_famous.frame;
        CGRect frameNameMessageText=_text2.frame;
        CGRect frameFamousText=_text3.frame;
        
        if(_flagAdd2==1){
            frameNameMessageText.size.height+=300*_flag2;
            _text2.frame=frameNameMessageText;
        }
        if(_flagAdd3==1)
        {
            frameFamousText.origin.y+=300*_flag2;
            _text3.frame=frameFamousText;
        }
       
        frameFamous.origin.y+=300*_flag2;
        
        _text.backgroundColor=[UIColor grayColor];
        if(_flag2==1)
        {
            _flag2=-1;
        }else{
            _flag2=1;
        }
        self.famous.frame=frameFamous;
        
    }];
}
//先贤

-(void)Famous:(UIButton *)but
{
    NSLog(@"Famous");
    if(_flagAdd3==0)
    {
        _flagAdd3=1;
       
        _text3.frame=CGRectMake(0,_famous.frame.origin.y+_famous.frame.size.height , 322, 0);
        _text3.text=@"这是一堆文章这是一堆文章这是一堆文章这是一堆文章这是一堆文章这是一堆文章这是一堆文章这是一堆文章这是一堆文章这是一堆文章这是一堆文章这是一堆文章这是一堆文章这是一堆文章";
        [_Scroll addSubview:_text3];
    }
    else{
        
    }
    //点击butten显示更多内容
    
    [UIView animateWithDuration:0.5 animations:^{
        CGRect frameMovie=_text3.frame;
        frameMovie.size.height+=300*_flag3;
        _text.backgroundColor=[UIColor grayColor];
        if(_flag3==1)
        {
            _flag3=-1;
        }else{
            _flag3=1;
        }
        _text3.frame=frameMovie;
    }];
}
//姓氏分布

-(void)WhereName:(UIButton *)but
{
    NSLog(@"WhereName");
    if(_flagAdd4==0)
    {
       
        _text4.frame=CGRectMake(0,_whereName.frame.origin.y+_whereName.frame.size.height , 322, 0);
        _text4.text=@"这是一堆文章这是一堆文章这是一堆文章这是一堆文章这是一堆文章这是一堆文章这是一堆文章这是一堆文章这是一堆文章这是一堆文章这是一堆文章这是一堆文章这是一堆文章这是一堆文章";
        _flagAdd4=1;
    [_Scroll addSubview:_text4];
    }else
    {
        
    }
    //点击butten加载更多内容
    
    [UIView animateWithDuration:0.5 animations:^{
        CGRect frameNameMessage=_nameMessage.frame;
        CGRect frameFamous=_famous.frame;
       
        CGRect frameWhereNameText=_text4.frame;
        CGRect frameNameMessageText=_text2.frame;
        CGRect frameFamousText=_text3.frame;
        if(_flagAdd2==1){
            frameNameMessageText.origin.y+=300*_flag4;
            _text2.frame=frameNameMessageText;
        }
        if(_flagAdd3==1)
        {
            frameFamousText.origin.y+=300*_flag4;
            _text3.frame=frameFamousText;
        }
        if(_flagAdd4==1){
            frameWhereNameText.size.height+=300*_flag4;
            _text4.frame=frameWhereNameText;
        }
        frameFamous.origin.y+=300*_flag4;
        frameNameMessage.origin.y+=300*_flag4;
        
        
        _text.backgroundColor=[UIColor grayColor];
        if(_flag4==1)
        {
            _flag4=-1;
        }else{
            _flag4=1;
        }
        self.famous.frame=frameFamous;
        self.nameMessage.frame=frameNameMessage;
       
       
    }];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
